package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.AndroidDevice;
import com.ruoyi.system.service.IAndroidDeviceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 安卓设备Controller
 * 
 * @author lingyu
 * @date 2024-02-29
 */
@RestController
@RequestMapping("/system/device")
public class AndroidDeviceController extends BaseController
{
    @Autowired
    private IAndroidDeviceService androidDeviceService;

    /**
     * 查询安卓设备列表
     */
    @PreAuthorize("@ss.hasPermi('system:device:list')")
    @GetMapping("/list")
    public TableDataInfo list(AndroidDevice androidDevice)
    {
        startPage();
        List<AndroidDevice> list = androidDeviceService.selectAndroidDeviceList(androidDevice);
        return getDataTable(list);
    }

    /**
     * 导出安卓设备列表
     */
    @PreAuthorize("@ss.hasPermi('system:device:export')")
    @Log(title = "安卓设备", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AndroidDevice androidDevice)
    {
        List<AndroidDevice> list = androidDeviceService.selectAndroidDeviceList(androidDevice);
        ExcelUtil<AndroidDevice> util = new ExcelUtil<AndroidDevice>(AndroidDevice.class);
        util.exportExcel(response, list, "安卓设备数据");
    }

    /**
     * 获取安卓设备详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:device:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(androidDeviceService.selectAndroidDeviceById(id));
    }

    /**
     * 新增安卓设备
     */
    @PreAuthorize("@ss.hasPermi('system:device:add')")
    @Log(title = "安卓设备", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AndroidDevice androidDevice)
    {
        return toAjax(androidDeviceService.insertAndroidDevice(androidDevice));
    }

    /**
     * 修改安卓设备
     */
    @PreAuthorize("@ss.hasPermi('system:device:edit')")
    @Log(title = "安卓设备", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AndroidDevice androidDevice)
    {
        return toAjax(androidDeviceService.updateAndroidDevice(androidDevice));
    }

    /**
     * 删除安卓设备
     */
    @PreAuthorize("@ss.hasPermi('system:device:remove')")
    @Log(title = "安卓设备", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(androidDeviceService.deleteAndroidDeviceByIds(ids));
    }
}
